@extends('layouts.app')

@section('content')
<div class="banner1"></div>
<div class="zhmm">
            <h2>找回密码</h2>
            <div class="zhmm_jd">

                <ul>
                    <li style="width:100px; padding-right:265px"><p>输入登录帐号</p><span {{ session('status') == null?'class=dqzt':'' }} >1</span></li>
                    <li style="width:100px; padding-right:265px"><p>验证身份</p><span {{ session('status') == 2?'class=dqzt':'' }}>2</span></li>
                    <li style="width:100px; padding-right:265px"><p>修改密码</p><span {{ session('status') == 3?'class=dqzt':'' }}>3</span></li>
                    <li style="width:100px;"><p>完成</p><span {{ session('status') == 4?'class=dqzt':'' }}>4</span></li>
                </ul>
                <div class="bjt"></div>
            </div>
            <div class="dlxq">
                
                @if(session('status')==2)
                <ul>
                <form class="form-horizontal" id="ff" method="POST" action="{{ route('password.checkCode') }}">
                        {{ csrf_field() }}                
                    <li><span>登录帐号</span><i style="font-size: 24px;"><input id="tel"  class="wby1" name="mobile" value="{{session('mobile')}}" disabled="disabled" placeholder="请输入您的手机号" type="text"></i></li>
                    <li><span>手机验证码</span><input class="wby3" name="mobile" type="hidden" value="{{session('mobile')}}">
                        <i><input class="wby3" id="inputCode" name="code" type="text"></i>
                    </li>
                    <li><a><input class="btn1" onclick="checkcode()" type="button" value="下一步"></a></li>
                </form>
                </ul>
                @elseif(session('status')==3)
                <ul>
                <form class="form-horizontal" id="ff" method="POST" action="{{ route('password.resetsPassword') }}">
                                        {{ csrf_field() }}                
                
                    <li><span>输入新密码</span><i><input class="wby1" id="pass1" name="password" placeholder="输入新密码" type="password"></i></li>
                    <li><span>再输入一次</span><i><input class="wby1" id="pass2" name="repassword" placeholder="再输入一遍" type="password"></i>
                    </li>
                    <li><input class="btn1" name="" style="width:270px;" onclick="reset1()" type="button" value="下一步"></li>
                </form>
                </ul>
                @elseif(session('status')==4)
                
                <div class="xgcg">
                <h4 style="text-align: start;margin-left: 59px;"><a href="/login"><img src="/front/Content/images/a12.jpg">密码修改成功，请重新登录！</a></h4>
            </div>
                @else
                <ul>
                <form class="form-horizontal" id="ff" method="POST" action="{{ route('password.email') }}">
                        {{ csrf_field() }}                
                    <li><span>登录帐号</span><i><input id="tel"  class="wby1" name="mobile" placeholder="请输入您的手机号" value="{{session('mobile')}}" type="text"></i></li>
                    <li><span>图片验证码</span>
                        <i><input class="wby3" id="inputCode" name="code" type="text"></i>
                        <!--<i><img src="/front/Content/images/a11.jpg"/></i>-->
                        <i><div class="code" id="checkCode" onclick="createCode()">{!!captcha_img()!!}</div></i>
                    </li>
                    <li><a><input class="btn1" onclick="sendsms(1)" type="button" value="下一步"></a></li>
                    </form>
                    </ul>
                @endif
                
            </div>
</div>
<script type="text/javascript">
function reset1(){
	var pass1 = $('#pass1').val();
	var pass2 = $('#pass2').val();
	if(pass1.length < 6  || pass2.length < 6 )
	{
	layer.msg('密码不能小于6位.');
	return false;
	}
	if(pass1 != pass2 )
	{
	layer.msg('两次密码不一致.');
	return false;
	}
	$('#ff').submit();
}
function checkcode(){
	var inputCode = $('#inputCode').val();
	if(inputCode.length != 4)
	{
	layer.msg('请填正确填写手机验证码.');
	return false;
	}
	$('#ff').submit();
}
function sendsms(type)
{
	
	var mobile = $('#tel').val();
	var inputCode = $('#inputCode').val();
	if(inputCode.length != 5)
		{
		layer.msg('请正确填写验证码.');
		return false;
		}
	if(!checkMobile(mobile))
		{
	layer.msg('请填写正确的手机号.');
	return false;
		}
	
	ajaxurl('/sendsms',{mobile:mobile, code: inputCode, type: 'reset'}, function(res){
		if(res.code == 0) {
			layer.msg('短信发送成功.')
			//alert(res.number)
			if(type==1)$('#ff').submit();
			
		}else{
			layer.msg('短信发送失败.')
		}
		console.log(res)
	})
}
function createCode()
{
	$('#checkCode img').attr('src', '/captcha?r='+Math.random());
}
</script>

@endsection
